import { LibResolver } from '../types'

export const MooliMobileResolver: LibResolver = {
  libName: 'mooli-mobile',
  style(name) {
    const getStyles = (name: string | string[]) => {
      if (typeof name === 'string') {
        return [`mooli-mobile/es/${name}/style/index.css`];
      }
      return name.map((n) => `mooli-mobile/es/${n}/style/index.css`)
    };
    const css = [`mooli-mobile/es/${name}/style/index.css`];
    if (/action-sheet/.test(name)) {
      return css.concat(getStyles(['popup', 'icon', 'button', 'loading']))
    }
    if (/b-address/.test(name)) {
      return css.concat(getStyles(['tabs', 'sticky', 'info', 'loading']))
    }
    if (/b-button/.test(name)) {
      return css.concat(getStyles(['button', 'loading', 'icon']))
    }
    if (/b-camera/.test(name)) {
      return css.concat(getStyles(['camera']))
    }
    if (/b-captcha/.test(name)) {
      return css.concat(getStyles(['captcha', 'overlay', 'popup', 'toast', 'icon', 'loading']))
    }
    if (/b-input/.test(name)) {
      return css.concat(getStyles(['field', 'cell', 'icon']))
    }
    if (/b-uploader/.test(name)) {
      return css.concat(getStyles(['uploader', 'toast', 'icon', 'loading', 'image', 'image-preview', 'swiper', 'popup']))
    }
    if (/button/.test(name)) {
      return css.concat(getStyles(['loading', 'icon']))
    }
    if (/captcha/.test(name)) {
      return css.concat(getStyles(['loading', 'overlay']))
    }
    if (/cascader/.test(name)) {
      return css.concat(getStyles(['tabs', 'icon', 'loading', 'sticky', 'info']))
    }
    if (/cell/.test(name)) {
      return css.concat(getStyles(['icon']))
    }
    if (/checkbox/.test(name)) {
      return css.concat(getStyles(['icon']))
    }
    if (/collapse/.test(name)) {
      return css.concat(getStyles(['cell']))
    }
    if (/datetime-picker/.test(name)) {
      return css.concat(getStyles(['picker', 'loading']))
    }
    if (/dialog/.test(name)) {
      return css.concat(getStyles(['button', 'loading', 'icon']))
    }
    if (/field/.test(name)) {
      return css.concat(getStyles(['cell', 'icon']))
    }
    if (/image/.test(name)) {
      return css.concat(getStyles(['icon']))
    }
    if (/image-preview/.test(name)) {
      return css.concat(getStyles(['swiper', 'icon', 'image', 'popup']))
    }
    if (/list/.test(name)) {
      return css.concat(getStyles(['loading']))
    }
    if (/notice-bar/.test(name)) {
      return css.concat(getStyles(['icon']))
    }
    if (/notify/.test(name)) {
      return css.concat(getStyles(['popup', 'icon']))
    }
    if (/number-keyboard/.test(name)) {
      return css.concat(getStyles(['popup', 'icon']))
    }
    if (/picker/.test(name)) {
      return css.concat(getStyles(['loading']))
    }
    if (/popup/.test(name)) {
      return css.concat(getStyles(['icon']))
    }
    if (/pull-refresh/.test(name)) {
      return css.concat(getStyles(['loading']))
    }
    if (/radio/.test(name)) {
      return css.concat(getStyles(['icon']))
    }
    if (/search/.test(name)) {
      return css.concat(getStyles(['field', 'cell', 'icon']))
    }
    if (/select/.test(name)) {
      return css.concat(getStyles(['search', 'field', 'cell', 'icon']))
    }
    if (/swiper/.test(name)) {
      return css.concat(getStyles(['icon']))
    }
    if (/switch/.test(name)) {
      return css.concat(getStyles(['loading']))
    }
    if (/tabs/.test(name)) {
      return css.concat(getStyles(['sticky', 'info']))
    }
    if (/toast/.test(name)) {
      return css.concat(getStyles(['icon', 'loading']))
    }
    if (/uploader/.test(name)) {
      return css.concat(getStyles(['icon', 'loading', 'image', 'image-preview', 'swiper', 'popup']))
    }
    return css;
  }
}

